package com.xyh.service.impl;

import com.xyh.entity.YxcCar;
import com.xyh.mapper.YxcCarMapper;
import com.xyh.service.YxcCarService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class YxcCarServiceImpl implements YxcCarService {

    @Resource
    private YxcCarMapper yxcCarMapper;

    @Override
    public List<YxcCar> selectAllCarByphone(String login_telephone) {
        return yxcCarMapper.selectAllCarByphone(login_telephone);
    }

    @Override
    public int deleteOneCar(int car_id,String owner_telephone) {
        return yxcCarMapper.deleteOneCar(car_id,owner_telephone);
    }

    @Override
    public int addOneCarByPhone(YxcCar yxcCar) {
        return yxcCarMapper.addOneCarByPhone(yxcCar);
    }

    @Override
    public int updateIsInitById(int car_id, int i) {
        return yxcCarMapper.updateIsInitById(car_id,i);
    }

    @Override
    public int getInitCarCount(String login_telephone) {
        return yxcCarMapper.getInitCarCount(login_telephone);
    }

    @Override
    public Integer getCarIdByCarNumber(String car_number) {
        return yxcCarMapper.getCarIdByCarNumber(car_number);
    }

    @Override
    public YxcCar selectOneCarByphoneAndPage(String login_telephone, int current_page, int page_size) {
        String current_pos = String.valueOf((current_page - 1) * page_size);
        String whereCondition = " where 1 = 1 and owner_telephone = " + login_telephone + " and flag = 1 limit " + current_pos + "," + page_size;
        return yxcCarMapper.selectOneCarByphoneAndPage(whereCondition);
    }
}
